/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package substancepk;

/*
*玩家类
*/

public class Player {
    
    
    //************************************************
    /* 属性 */
    private String    playerName;      //玩家名
    private String    playerPwd;       //玩家密码
    private int       playerId;        //玩家账号
    private int       playerGrade;     //玩家等级
    private int       playerScore;     //玩家积分
    //************************************************
    
    
    
    //************************************************
    /* 构造器 */
    public Player(){}
    
    public Player(int playerId){
        this.playerId = playerId;
    }
    //************************************************
    
    
    
    //************************************************
    /* Setters and Getters */
    
    public String getPlayerName() {
        return playerName;
    }

    public void setPlayerName(String playerName) {
        this.playerName = playerName;
    }

    public String getPlayerPwd() {
        return playerPwd;
    }

    public void setPlayerPwd(String playerPwd) {
        this.playerPwd = playerPwd;
    }

    public int getPlayerId() {
        return playerId;
    }

    public void setPlayerId(int playerId) {
        this.playerId = playerId;
    }

    public int getPlayerGrade() {
        calcGrade();
        return playerGrade;
    }

    public void setPlayerGrade(int playerGrade) {
        this.playerGrade = playerGrade;
    }

    public int getPlayerScore() {
        return playerScore;
    }

    public void setPlayerScore(int playerScore) {
        this.playerScore = playerScore;
    }
    
    //************************************************
    
    

    //************************************************
    /* toString */
    public String toString(){
        return "Player{" 
                + "playerName=" + playerName 
                + ", playerId=" + playerId 
                + ", playerGrade=" + playerGrade 
                + ", playerScore=" + playerScore + '}';
    }
    //************************************************
    
    
    
    //************************************************
    /* 其他方法 */
    // 计算等级
    public void calcGrade() {
        if(this.playerScore >= 0 && this.playerScore < 20){
            this.playerGrade = 1;
        }
        else if(this.playerScore < 40){
            this.playerGrade = 2;
        }
        else if(this.playerScore < 60){
            this.playerGrade = 3;
        }
        else if(this.playerScore < 80){
            this.playerGrade = 4;
        }
        else{
            this.playerGrade = 5;
        }
    }
    //************************************************
    
}
